import {createRouter, createWebHistory} from 'vue-router';
import Index from "@/layouts/Index.vue";
import Home from '@/pages/Index.vue';
import RestaurantList from '@/pages/restaurant/Restaurant.vue';
import RestaurantDetail from '@/pages/restaurant/RestaurantDetail.vue';
import UserProfile from '@/pages/user/UserProfile.vue';
import NotFound from '@/pages/NotFound.vue';
import LoginRegister from '@/pages/LoginRegister.vue';

const routes = [
    {
        path: '/',
        component: Index,
        children: [
            {
                path: '/',
                component: Home
            },
            {
                path: '/restaurants',
                component: RestaurantList
            },
            {
                path: '/restaurant/:id',
                name: 'RestaurantDetail',
                component: RestaurantDetail
            },
            {
                path: '/user',
                component: UserProfile
            },

        ]
    },
    {
        path: '/auth',
        component: LoginRegister
    },
    // 将匹配所有内容并将其放在 `route.params.pathMatch` 下
    {path: '/:pathMatch(.*)*', name: 'NotFound', component: NotFound},
];

const router = createRouter({
    history: createWebHistory(),
    routes
});

export default router;